FROM koala-acr-registry.cn-shanghai.cr.aliyuncs.com/test/base:0.0.4

ENV LANG en_US.UTF-8
RUN apk add --update --no-cache ttf-dejavu fontconfig && rm -rf /var/cache/apk/* \
 && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
 && echo 'Asia/Shanghai' >/etc/timezone

EXPOSE 80

WORKDIR /opt

COPY ./target/koala-keymanagement.jar ./koala-keymanagement.jar

#COPY ./scripts/startup.sh ./startup.sh
#
#RUN chmod a+x /opt/startup.sh


ARG APP_NAME="koala-keymanagement"
ARG JAR_FILE="/opt/koala-keymanagement.jar"
ARG	JVM_XMX="1536M"
ARG	JVM_XMS="500M"
ARG	JVM_XMN="400M"
ARG JVM_MAXMETASPACESIZE="128M"

ENV DOCKER_APP_NAME=$APP_NAME
ENV DOCKER_JAR_FILE=$JAR_FILE
ENV DOCKER_JVM_XMX=$JVM_XMX
ENV DOCKER_JVM_XMS=$JVM_XMS
ENV DOCKER_JVM_XMN=$JVM_XMN
ENV DOCKER_JVM_MAXMETASPACESIZE=$JVM_MAXMETASPACESIZE

#ENTRYPOINT ["/opt/startup.sh", "koalaCMS", "/opt/koalaCMS.jar","$JVM_ARG"]

ENTRYPOINT java -Xmx$DOCKER_JVM_XMX -Xms$DOCKER_JVM_XMS -Xmn$DOCKER_JVM_XMN -XX:MaxMetaspaceSize=$DOCKER_JVM_MAXMETASPACESIZE -XX:MetaspaceSize=$DOCKER_JVM_MAXMETASPACESIZE -XX:+UseConcMarkSweepGC -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:+PrintGCApplicationStoppedTime -XX:+PrintHeapAtGC  -Xloggc:/opt/gc.log -javaagent:/opt/pinpoint-agent-2.1.0/pinpoint-bootstrap-2.1.0.jar -Dpinpoint.applicationName=$DOCKER_APP_NAME -Dpinpoint.agentId=$(ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d \"addr:\") -jar $DOCKER_JAR_FILE
